package composite_pattern.abstract_file.file;

import composite_pattern.abstract_file.AbstractFile;

import java.util.LinkedList;
import java.util.List;

public class Folder extends AbstractFile {

    private String name;
    public Folder(String name){
        this.name = name;
    }

    public String getName() {
        return name;
    }

    private List<AbstractFile> files = new LinkedList<>();


    @Override
    public void display() {
        System.out.println("我是一个文件夹");
    }

    public void add(AbstractFile abstractFile){
        files.add(abstractFile);
    }

    public void remove(AbstractFile abstractFile){
        files.remove(abstractFile);
    }

    public void getChild(){
        System.out.println(this.name + ":");
        for (AbstractFile abstractFile : files) {
            System.out.println("\t" + abstractFile.getName());
        }
    }
}
